package com.dangdang.action;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.util.ServletContextAware;

import com.opensymphony.xwork2.ActionContext;

/**
 * 实现Request,Response,Session,Application
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-1-25
 */
public class BaseAction implements ServletRequestAware, ServletResponseAware,
		SessionAware, ServletContextAware {
	protected ActionContext actionCtx = ActionContext.getContext();

	protected HttpServletRequest request;

	protected HttpServletResponse response;

	protected ServletContext application;

	protected Map<String, Object> session;

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	public void setServletContext(ServletContext application) {
		this.application = application;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	protected void put(String name, Object value) {
		actionCtx.put(name, value);
	}

	protected Object get(String name) {
		return actionCtx.get(name);
	}
}
